package java111;

import java.util.Scanner;

public class Day24 {
    public boolean IsBalanced_Solution (TreeNode pRoot) {
        if(pRoot == null){
            return true;
        }
        return !(height(pRoot) == -1);
    }
    public int height(TreeNode pRoot){
        if(pRoot == null){
            return 0;
        }
        int leftTree = height(pRoot.left);
        if(leftTree == -1){
            return -1;
        }
        int rightTree = height(pRoot.right);
        if(rightTree == -1){
            return -1;
        }
        if(Math.abs(leftTree-rightTree) <= 1){
            return Math.max(leftTree,rightTree) + 1;
        } else {
            return -1;
        }
    }

    //https://www.nowcoder.com/practice/a5a0b05f0505406ca837a3a76a5419b3?tqld=40416&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] arr = new int[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                arr[i][j] = in.nextInt();
            }
        }
        int[][] tmp = new int[n+1][n+1];
        // 前缀和数组 tmp[i+1][j+1] 表示 从 (0, 0) 位置到 (i, j)位置的矩阵和
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                tmp[i][j] = tmp[i-1][j] + tmp[i][j-1] - tmp[i-1][j-1] + arr[i-1][j-1];
            }
        }
        int res = -128;
        for(int x1 = 1; x1 <= n; x1++){
            for(int y1 = 1; y1 <= n; y1++){
                for(int x2 = x1; x2 <= n; x2++){
                    for(int y2 = y1; y2 <= n; y2++){
                        res = Math.max(res, tmp[x2][y2] - tmp[x2][y1-1] - tmp[x1-1][y2] + tmp[x1-1][y1-1]);
                    }
                }
            }
        }
        System.out.println(res);
    }


    //https://ac.nowcoder.com/acm/problem/230830
    public static void main3(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String str = in.next();
        int sum0 = 0, sum1 = 0;
        for(int i = 0; i < str.length(); i++){
            if(str.charAt(i) == '0'){
                sum0++;
            } else {
                sum1++;
            }
        }
        int left = 0, right = 0, res = 0, count0 = 0, count1 = 0;
        for(; right < n-1; right++){
            if(str.charAt(right) == '0'){
                count0++;
            } else {
                count1++;
            }
            if(right - left + 1 == n/2){
                if(sum0 == 2 * count0 && sum1 == 2 * count1){
                    res += 2;
                }
                if(str.charAt(left++) == '0'){
                    count0--;
                } else {
                    count1--;
                }
            }
        }
        System.out.println(res);
    }
}
